package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.LitemallBookBoxMapper;
import org.linlinjava.litemall.db.domain.LitemallBookBox;
import org.linlinjava.litemall.db.domain.LitemallBookBoxExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Administrator
 */
@Service
public class LitemallBookBoxService {
    @Autowired
    private LitemallBookBoxMapper bookBoxMapper;

    public LitemallBookBox findById(Integer id) {
        return bookBoxMapper.selectByPrimaryKey(id);
    }

    public LitemallBookBox findByIdAndUserId(Integer id,Integer userId) {
        LitemallBookBoxExample example = new LitemallBookBoxExample();
        example.or().andIdEqualTo(id).andUserIdEqualTo(userId);
        return bookBoxMapper.selectOneByExample(example);
    }

    public LitemallBookBox findByGoodsProductId(Integer goodsProductId) {
        LitemallBookBoxExample example = new LitemallBookBoxExample();
        example.or().andGoodsProductIdEqualTo(goodsProductId);
        return bookBoxMapper.selectOneByExample(example);
    }

    public LitemallBookBox findByUserIdAndGoodsProductId(Integer userId,Integer goodsProductId) {
        LitemallBookBoxExample example = new LitemallBookBoxExample();
        example.or().andUserIdEqualTo(userId).andGoodsProductIdEqualTo(goodsProductId);
        return bookBoxMapper.selectOneByExample(example);
    }


}
